<template>
  <view class="game-header">
    <!-- 顶部信息栏 -->
    <view class="top-info-bar">
      <view class="player-info">
        <view class="player-avatar">
          <image :src="playerAvatar" class="avatar-img" mode="aspectFill"></image>
        </view>
        <view class="player-stats">
          <view class="stat-item">
            <text class="stat-icon">🪙</text>
            <text class="stat-value">{{ playerGold }}</text>
          </view>
          <view class="stat-item">
            <text class="stat-icon">❤️</text>
            <text class="stat-value">{{ playerTrust }}</text>
          </view>
          <view class="stat-item">
            <text class="stat-icon">⭐</text>
            <text class="stat-value">Lv.{{ playerLevel }}</text>
          </view>
        </view>
      </view>
      
      <view class="game-progress">
        <view class="trust-progress">
          <text class="round-text">第{{ currentRound }}轮/{{ maxRounds }}轮</text>
          <view class="progress-bar">
            <view class="progress-fill" :style="{ width: trustProgressPercent + '%' }"></view>
          </view>
          <text class="progress-text">{{ trustProgressPercent }}%</text>
        </view>
      </view>
      
      <view class="exchange-btn" @click="showExchange">
        <text class="exchange-icon">💎</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'GameHeader',
  props: {
    playerAvatar: {
      type: String,
      default: '/static/logo.png'
    },
    playerGold: {
      type: Number,
      default: 0
    },
    playerTrust: {
      type: Number,
      default: 0
    },
    playerLevel: {
      type: Number,
      default: 1
    },
    currentRound: {
      type: Number,
      default: 1
    },
    maxRounds: {
      type: Number,
      default: 5
    },
    trustProgressPercent: {
      type: Number,
      default: 0
    }
  },
  methods: {
    showExchange() {
      this.$emit('show-exchange')
    }
  }
}
</script>

<style scoped>
.game-header {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 0 0 20rpx 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}

.top-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20rpx;
  gap: 16rpx;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 12rpx;
}

.player-avatar {
  width: 50rpx;
  height: 50rpx;
  border-radius: 50%;
  overflow: hidden;
  border: 2rpx solid rgba(255, 255, 255, 0.3);
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.player-stats {
  display: flex;
  gap: 12rpx;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4rpx;
  background: rgba(255, 255, 255, 0.2);
  padding: 6rpx 12rpx;
  border-radius: 20rpx;
  backdrop-filter: blur(10rpx);
}

.stat-icon {
  font-size: 16rpx;
}

.stat-value {
  font-size: 14rpx;
  font-weight: bold;
  color: white;
}

.game-progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8rpx;
}

.trust-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4rpx;
}

.round-text {
  font-size: 16rpx;
  font-weight: bold;
  color: white;
}

.progress-bar {
  width: 120rpx;
  height: 8rpx;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4rpx;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4cd964, #5ac8fa);
  border-radius: 4rpx;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12rpx;
  color: rgba(255, 255, 255, 0.8);
}

.exchange-btn {
  width: 50rpx;
  height: 50rpx;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10rpx);
  border: 2rpx solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.exchange-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.3);
}

.exchange-icon {
  font-size: 20rpx;
}

/* 移动端优化 */
@media (max-width: 768rpx) {
  .top-info-bar {
    padding: 12rpx;
    gap: 8rpx;
  }
  
  .player-avatar {
    width: 40rpx;
    height: 40rpx;
  }
  
  .stat-item {
    padding: 4rpx 8rpx;
    gap: 2rpx;
  }
  
  .stat-icon {
    font-size: 14rpx;
  }
  
  .stat-value {
    font-size: 12rpx;
  }
  
  .round-text {
    font-size: 14rpx;
  }
  
  .progress-bar {
    width: 80rpx;
    height: 6rpx;
  }
  
  .exchange-btn {
    width: 40rpx;
    height: 40rpx;
  }
  
  .exchange-icon {
    font-size: 16rpx;
  }
}
</style>

